using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Admin_Admin_SelectClassify : Admin, IRequiresSessionState
{
	private Shop_Class shopclass;
	public string m_Script = "";
	protected TextBox ProductList;
	protected HiddenField hfProductList;
	protected ObjectDataSource ObjectDataSource2;
	protected GridView GridView1;
	protected ObjectDataSource ObjectDataSource1;
	protected Literal script_literal;
	protected HtmlForm productform;
	public Shop_Class Shopclass
	{
		get
		{
			if (this.shopclass == null)
			{
				this.shopclass = new Shop_Class(this.conn);
			}
			return this.shopclass;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (!base.admin.CheckAdminPower(20))
			{
				base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Class");
				base.WriteRightErrMsg();
			}
			this.hfProductList.Value = Fetch.Get("DefaultValue");
			if (!string.IsNullOrEmpty(this.hfProductList.Value))
			{
				string sql = "select ClassID,ClassName from HLShop_Class where ClassID in (" + this.hfProductList.Value + ")";
				DataTable dataTable = this.conn.GetDataTable(sql);
				string text = "";
				string text2 = "";
				string[] array = this.hfProductList.Value.Split(new char[]
				{
					','
				});
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					text = text + dataTable.Rows[i]["ClassName"].ToString() + ",";
					text2 = text2 + dataTable.Rows[i]["ClassID"].ToString() + ",";
				}
				if (text != "")
				{
					text = text.Substring(0, text.Length - 1);
					text2 = text2.Substring(0, text2.Length - 1);
				}
				this.ProductList.Text = text;
				this.hfProductList.Value = text2;
			}
			this.m_Script = "<SCRIPT language=JavaScript type=text/javascript>";
			this.m_Script += "var myClass =";
			this.m_Script += "[";
			string sql2 = "select * from HLShop_Class where ParentID=0 order by ClassID asc";
			DataTable dataTable2 = this.conn.GetDataTable(sql2);
			this.GridView1.DataSource = dataTable2;
			this.GridView1.DataBind();
		}
	}
	protected string DisplayClassName(DataRow hl_class)
	{
		string result;
		if (hl_class != null && hl_class.ToString() != "")
		{
			string text = "";
			string text2 = hl_class["ClassID"].ToString();
			string text3 = hl_class["ClassName"].ToString();
			string text4 = string.Concat(new string[]
			{
				"<a style=\"cursor: pointer;\" onclick=\"add('",
				text3,
				"','",
				text2,
				"')\">",
				text3,
				"</a>"
			});
			string text5 = text;
			text = string.Concat(new string[]
			{
				text5,
				text4,
				"&nbsp;(子分类 ：<b>",
				hl_class["Child"].ToString(),
				"</b>)"
			});
			result = text;
		}
		else
		{
			result = "";
		}
		return result;
	}
	protected void GridView1_DataBound(object sender, EventArgs e)
	{
		this.script_literal.Text = this.m_Script + "[0,0,0,0]];</script>";
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			if (!base.admin.CheckAdminPower(20))
			{
				LinkButton linkButton = (LinkButton)e.Row.FindControl("btnDelete");
				linkButton.Visible = false;
			}
			e.Row.Attributes.Add("onmouseover", "c = this.style.backgroundColor;this.style.backgroundColor = '#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
			e.Row.Attributes.Add("id", "tr" + DataBinder.Eval(e.Row.DataItem, "ClassID"));
			int num = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ClassID"));
			int num2 = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Child"));
			int num3 = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ParentID"));
			int num4 = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Depth"));
			if (num4 > 0)
			{
				e.Row.Attributes.Add("style", "display:''");
			}
			object script = this.m_Script;
			this.m_Script = string.Concat(new object[]
			{
				script,
				"[",
				num,
				",",
				num4,
				",",
				num2,
				",",
				num3,
				"],"
			});
		}
	}
}
